{block name=body} 
{* Define the function *} 
{function name=render_list level=0}
	{foreach $items as $item}
		{if $item.url}
		<tr {if $item.published eq '0'}class="draft"{/if}>
			<td>{for $var=1 to $level}- {/for}<b>{$item.title} </b>{if $item.published eq '0'}<small>| 草稿</small>{/if}</td>
			<td><b>{$item.record.location_contact}</b></td>
			<td><b>{$item.record.location_phone}</b></td>
			<td><b>{$item.record.location_street}</b></td>
			<td>{if $item.url} <a href='{$item.url}' class='btn btn-small btn-warning pull-right'><span class="glyphicon glyphicon-pencil"></span> 编辑</a> {/if}
			</td>
			<td>
			{if $item.url_delete && !$item.record.location_object_id}
			<a href='{$item.url_delete}' onclick="return ConfirmDelete();" class='btn btn-small btn-danger pull-right'><span class="glyphicon glyphicon-trash"></span> 删除</a>
			{else}
			<a href='{$item.url_delete}' onclick="return ConfirmDelete();" class='btn btn-small btn-danger pull-right' style="margin-left: 10px"><span class="glyphicon glyphicon-trash"></span> 删除</a>
			<!-- <a href='javascript:void();' class='btn btn-small btn-info pull-right'><span class="glyphicon glyphicon-download-alt"></span> 同步自一卡易</a> -->
			{/if}
			</td>
		</tr>
		{/if}
		{if count($item.subs) > 0} {call name=render_list items=$item.subs level=$level+1} {/if} 
	{/foreach} 
{/function}

<div class="row ">
	<table class="table table-bordered table-striped table-hover">
		<thead>
			<tr>
				<th colspan="6">{$zone|upper}
 				<a href="/admin/edit/{$path}" class='btn btn-small btn-success pull-right' style="margin-left: 10px"><span class="glyphicon glyphicon-plus"></span> 添加</a>
				<!-- <a href="#" onclick="ecarde_sync()" class='btn btn-small btn-primary pull-right'><span class="glyphicon glyphicon-refresh"></span> 与一卡易同步</a>  -->
				</th>
			</tr>
			<tr>
				<th>店铺名称</th>
				<th>联系人</th>
				<th>电话</th>
				<th>详细地址</th>
				<th colspan="2">操作</th>
			</tr>
		</thead>
		<tbody>{call name=render_list items=$list}
		</tbody>
	</table>
</div>
<script>
function ecarde_sync() {
	$.ajax({
		type: "POST",
	    url: "/admin/includes/processes/processes-sync.php",
        data: {
          "type": "location"
        },
		cache: false,
		dataType: "json",
	    success: function(data) {
	    	if(data.success){
	    		window.location.href=data.url;
	    	}else{
	    		alert(data.error);
	    	}
	    },
		error: function(){
			console.log('AJAX error');
        }
	});
}
</script>
{/block}
